import type { FC, PropsWithChildren } from "react";
import useAppStore, { selectToken } from "@/store/app-store";
import { Navigate } from "react-router-dom";

const AuthRoot:FC<PropsWithChildren> =({children}) =>{
    //拿到token
    const token =useAppStore(selectToken)

    if(token){
        //已登录
        return<>{children}</>
    } else{
        //未登录
        return <Navigate to="/login" replace/>
    }
    
    
}







export default AuthRoot